package pers.ljf.escloud.common.dto;

import java.io.Serializable;

public class ResultDTO<T> implements Serializable {

    private static final long serialVersionUID = 6210465027884734563L;

    private T data;

    private Boolean success;

    private String message;

    private Integer code;

    public ResultDTO() {
    }

    public ResultDTO(T data) {
        this.data = data;
        this.success = true;
        code = RespCode.SUCCESS.getCode();
    }

    public ResultDTO(String message, Integer code) {
        this.success = false;
        this.message = message;
        this.code = code;
    }

    public ResultDTO(Boolean success, String message, Integer code) {
        this.success = success;
        this.message = message;
        this.code = code;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public Boolean isSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("ResultDTO{");
        sb.append("data=").append(data);
        sb.append(", success=").append(success);
        sb.append(", message='").append(message).append('\'');
        sb.append(", code=").append(code);
        sb.append('}');
        return sb.toString();
    }
}
